<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 100px;
            height: 100px;
            border: 1px solid #000;
        }
    </style>
</head>
<body>
    <div></div>
    <hr/>
    <button id="btn">对事件解绑</button>
    <script>
        var div = document.querySelector('div');
        div.addEventListener('click',fn)
        function fn() {
            alert('ok')
        }
        div.addEventListener('mouseover' ,function() {
            this.style.backgroundColor = 'pink'
        })
        // 当鼠标点击按钮时 将 div身上的事件解绑
        document.querySelector('#btn').addEventListener('click',function() {
            div.removeEventListener('click', fn)
        })
    </script>
</body>
</html>